using System;
using System.ComponentModel;
using System.Data;
using System.Collections.Generic;

namespace PlacementManager
{
   
    public partial class vwUnitEnrolmentsForStudentsComponent
    {
		//
		// TODO: Add constructor logic here
		//
        /// <summary>
        /// Selects all records from the database table.
        /// </summary>
        /// <returns>A collection of objects of a type representing a row in the database table.</returns>
		[DataObjectMethodAttribute(DataObjectMethodType.Select, true)]
        public List<vwUnitEnrolmentsForStudents> SelectAllWUserIdEnrolmentStatus(int userId, int isCurrentlyEnrolled, string sortExpression)
        {
            List<vwUnitEnrolmentsForStudents> listvwUnitEnrolmentsForStudents = new List<vwUnitEnrolmentsForStudents>();
            PlacementManager.DAL.vwUnitEnrolmentsForStudents_DAL o = new PlacementManager.DAL.vwUnitEnrolmentsForStudents_DAL();

            DataSet ds = o.SelectAllWUserIdEnrolmentStatus(userId,isCurrentlyEnrolled);

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                listvwUnitEnrolmentsForStudents.Add(new vwUnitEnrolmentsForStudents((int)row["UnitId"], (string)row["UnitCode"], (string)row["UnitName"], (string)row["UnitDescription"], (int)row["DivisionId"], (int)row["YearLevel"], (bool)row["IsActive"], (DateTime)row["DateCreated"], (string)row["CreatedBy"], (DateTime)row["DateUpdated"], (string)row["UpdatedBy"], (bool)row["IsCurrentlyEnrolled"], (bool)row["IsActiveLink"], (string)row["UserName"], (string)row["FirstName"], (string)row["LastName"], (string)row["IdNumber"], (int)row["UserId"]));
            }
			
			if (sortExpression == string.Empty)
            {
                sortExpression = "DateCreated desc";
            }

            listvwUnitEnrolmentsForStudents.Sort(new vwUnitEnrolmentsForStudentsComparer(sortExpression));
            return listvwUnitEnrolmentsForStudents;
        }
	}
}
